<template>
  <div class="user_container">
    <div class="userBJ"></div>
    <div class="user_content">
      <div class="header">
        <el-tabs v-model="activeName">
          <el-tab-pane label="个人信息" name="user"></el-tab-pane>
          <el-tab-pane label="我的收藏" name="shouchang"></el-tab-pane>
        </el-tabs>
      </div>
      <div v-if="activeName == 'user'" class="users">
        <div class="left">
          <el-card class="card">
            <div slot="header" style="text-align: center">
              <span>个人信息</span>
            </div>
            <div class="cardContent">
              <div class="touxiang">
                <img
                  src="../../assets/touxiang.webp"
                  width="100%"
                  height="100%"
                  alt=""
                />
              </div>
              <div class="text">
                <span>用户名：{{ userInfo.username }}</span>
                <span>性别：{{ userInfo.sex }}</span>
                <span>年龄：{{ userInfo.age }}</span>
                <span>邮箱地址：{{ userInfo.email }}</span>
                <span>练习电话：{{ userInfo.phone }}</span>
              </div>
            </div>
          </el-card>
        </div>
        <div class="right">
          <el-calendar v-model="value"> </el-calendar>
        </div>
      </div>
      <div v-else class="shouchang">
        <el-table :data="collectionCurriculum" border style="width: 100%">
          <el-table-column prop="title" label="课程名称" align="center">
          </el-table-column>
          <el-table-column prop="image" label="课程图片" align="center">
            <template slot-scope="scope">
              <img :src="scope.row.image" width="100%" height="100%" alt="" />
            </template>
          </el-table-column>
          <el-table-column
            prop="time"
            align="center"
            label="课程课时"
          ></el-table-column>
          <el-table-column label="操作" align="center">
            <template slot-scope="scope">
              <el-button
                size="mini"
                type="danger"
                @click="
                  collectChange({
                    id: scope.row.id,
                    collect: false,
                  })
                "
                >取消收藏</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  computed: {
    ...mapState(["collectionCurriculum"]),
  },
  data() {
    return {
      value: new Date(),
      activeName: "user",
      userInfo: JSON.parse(localStorage.getItem("userInfo")),
    };
  },
  methods: {
    collectChange(e) {
      this.$store.dispatch("Curriculum", e);
      this.$message({
        message: "取消收藏",
        type: "warning",
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.user_container {
  width: 100%;
  .userBJ {
    width: 100%;
    height: 100px;
    background-image: url("../../assets/bj3.png");
    background-size: 100% 100%;
    margin-bottom: 10px;
  }
  .user_content {
    width: 1000px;
    margin: 0 auto;
    // min-height: 500px;
    background-color: #fff;
    box-shadow: 0px 0px 5px 2px rgba(0, 0, 0, 0.3);
    border-radius: 3px;
    padding: 15px;
    box-sizing: border-box;
    .users {
      width: 100%;
      display: flex;
      .left {
        width: 30%;
        height: 350px;
        .card {
          height: 100% !important;
        }
        .cardContent {
          display: flex;
          flex-direction: column;
          align-items: center;
          .touxiang {
            width: 100px;
            height: 100px;
            overflow: hidden;
            border-radius: 100px;
          }
          .text {
            width: 100%;
            height: 160px;
            font-size: 12px;
            padding: 20px;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;
            justify-content: space-around;
          }
        }
      }
      .right {
        width: 70%;
        height: 400px;
        ::deep.el-calendar-day {
          height: 38px !important;
        }
      }
    }
  }
}
</style>
